/**
 */
package de.thwildau.tm.moses.avro.avdl.impl;

import de.thwildau.tm.moses.avro.avdl.AvdlPackage;
import de.thwildau.tm.moses.avro.avdl.Definitions;
import de.thwildau.tm.moses.avro.avdl.Imports;
import de.thwildau.tm.moses.avro.avdl.Protocol;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Protocol</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.avro.avdl.impl.ProtocolImpl#getProtocolName <em>Protocol Name</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.avro.avdl.impl.ProtocolImpl#getImports <em>Imports</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.avro.avdl.impl.ProtocolImpl#getDefinitions <em>Definitions</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ProtocolImpl extends MinimalEObjectImpl.Container implements Protocol
{
  /**
   * The default value of the '{@link #getProtocolName() <em>Protocol Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getProtocolName()
   * @generated
   * @ordered
   */
  protected static final String PROTOCOL_NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getProtocolName() <em>Protocol Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getProtocolName()
   * @generated
   * @ordered
   */
  protected String protocolName = PROTOCOL_NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getImports() <em>Imports</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getImports()
   * @generated
   * @ordered
   */
  protected EList<Imports> imports;

  /**
   * The cached value of the '{@link #getDefinitions() <em>Definitions</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDefinitions()
   * @generated
   * @ordered
   */
  protected EList<Definitions> definitions;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ProtocolImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return AvdlPackage.Literals.PROTOCOL;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getProtocolName()
  {
    return protocolName;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setProtocolName(String newProtocolName)
  {
    String oldProtocolName = protocolName;
    protocolName = newProtocolName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AvdlPackage.PROTOCOL__PROTOCOL_NAME, oldProtocolName, protocolName));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Imports> getImports()
  {
    if (imports == null)
    {
      imports = new EObjectContainmentEList<Imports>(Imports.class, this, AvdlPackage.PROTOCOL__IMPORTS);
    }
    return imports;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Definitions> getDefinitions()
  {
    if (definitions == null)
    {
      definitions = new EObjectContainmentEList<Definitions>(Definitions.class, this, AvdlPackage.PROTOCOL__DEFINITIONS);
    }
    return definitions;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case AvdlPackage.PROTOCOL__IMPORTS:
        return ((InternalEList<?>)getImports()).basicRemove(otherEnd, msgs);
      case AvdlPackage.PROTOCOL__DEFINITIONS:
        return ((InternalEList<?>)getDefinitions()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case AvdlPackage.PROTOCOL__PROTOCOL_NAME:
        return getProtocolName();
      case AvdlPackage.PROTOCOL__IMPORTS:
        return getImports();
      case AvdlPackage.PROTOCOL__DEFINITIONS:
        return getDefinitions();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case AvdlPackage.PROTOCOL__PROTOCOL_NAME:
        setProtocolName((String)newValue);
        return;
      case AvdlPackage.PROTOCOL__IMPORTS:
        getImports().clear();
        getImports().addAll((Collection<? extends Imports>)newValue);
        return;
      case AvdlPackage.PROTOCOL__DEFINITIONS:
        getDefinitions().clear();
        getDefinitions().addAll((Collection<? extends Definitions>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case AvdlPackage.PROTOCOL__PROTOCOL_NAME:
        setProtocolName(PROTOCOL_NAME_EDEFAULT);
        return;
      case AvdlPackage.PROTOCOL__IMPORTS:
        getImports().clear();
        return;
      case AvdlPackage.PROTOCOL__DEFINITIONS:
        getDefinitions().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case AvdlPackage.PROTOCOL__PROTOCOL_NAME:
        return PROTOCOL_NAME_EDEFAULT == null ? protocolName != null : !PROTOCOL_NAME_EDEFAULT.equals(protocolName);
      case AvdlPackage.PROTOCOL__IMPORTS:
        return imports != null && !imports.isEmpty();
      case AvdlPackage.PROTOCOL__DEFINITIONS:
        return definitions != null && !definitions.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (protocolName: ");
    result.append(protocolName);
    result.append(')');
    return result.toString();
  }

} //ProtocolImpl
